package spring.board.service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import spring.board.dao.MainDao;
import spring.board.vo.Board;
import spring.board.vo.Comments;
import spring.board.vo.FriendlistVO;
import spring.board.vo.MemberInfo;

public class MainServiceImpl implements MainService {
	

	private MainDao mainDao;
	private StringBuffer strBuffer=null;


	public void setMainDao(MainDao mainDao) {
		this.mainDao = mainDao;
	}
	
	@Override
		public int writeComment(Comments comments) {
		return mainDao.writeComment(comments);
	}
	
	@Override
	public List<Comments> getComments(String num){
		return mainDao.getComments(num);
	}
	
	@Override
	public List getList(Map<String, Object> paramMap) {
		return mainDao.getList(paramMap);
	}
	
	@Override
	public String getPassword(String username) {
		return mainDao.getPassword(username);
	}


	@Override
	public void registMember(MemberInfo member) {
		mainDao.registMember(member);
		
	}
	@Override
	public void registFriend(String username){
		mainDao.registFriend(username);
		
	}

	@Override
	public List<FriendlistVO> searchFriend(String username) {
		// TODO Auto-generated method stub
		try {
			if(strBuffer!=null){
				strBuffer.delete(0, strBuffer.capacity());
			}
			strBuffer=new StringBuffer("%");
			strBuffer.append(username);
			strBuffer.append("%");
		} catch (Exception e) {
			// TODO: handle exception
		}
		
		return mainDao.searchFriend(strBuffer.toString());
	}
}
